#pragma once


#include "HashTable.h"


template<class K, class V>
struct mapKofT
{
	K operator()(const pair<K, V>& kv)
	{
		return kv.first;
	}
};

template<class K, class V>
class Unordered_map
{
public:
	typedef typename hash_bucket::HashTable<K, pair<const K, V>, mapKofT<K, V>>::iterator iterator;
	typedef typename hash_bucket::HashTable<K, pair<const K, V>, mapKofT<K, V>>::const_iterator const_iterator;

	pair<iterator, bool> insert(const pair<K, V>& kv)
	{
		return _ht.insert(kv);
	}

	V& operator[](const K& key)
	{
		return _ht.insert(make_pair(key, V())).first->second;
	}
	bool Erase(const K& key)
	{
		return _ht.Erase(key);
	}
	iterator begin()
	{
		return _ht.begin();
	}

	iterator end()
	{
		return _ht.end();
	}
	const_iterator begin() const
	{
		return _ht.begin();
	}

	const_iterator end() const
	{
		return _ht.end();
	}

private:
	hash_bucket::HashTable<K, pair<const K, V>, mapKofT<K, V>> _ht;
};